#include <QtGui/QApplication>
#include "mainwindow.h"
#include "canves/omglcanves.h"
#include "document/omdocument.h"
#include "renderer/omrenderer.h"
#include "operations/omoperationmanager.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;

    // Set central widget
    OMGLCanves* glCanves = new OMGLCanves(&w);
    w.setCentralWidget(glCanves);

    // connect work flow
    OMDocument* omDocument = new OMDocument;
    OMRenderer* omRenderer = new OMRenderer;
    omRenderer->setDocument(omDocument);
    omRenderer->setCanves(glCanves);
    w.setDocument(omDocument);
    OMOperationManager* omOperationManager = new OMOperationManager();
    omOperationManager->setMainWindow(&w);
    omOperationManager->setRenderer(omRenderer);
    w.setOperationManager(omOperationManager);

    omOperationManager->initOperations();

    QObject::connect(glCanves, SIGNAL(renderScene()), omRenderer, SLOT(renderDocument()));
    QObject::connect(omDocument, SIGNAL(fileLoaded()), omRenderer, SLOT(resetScene()));

    // Show main window
    w.show();

    return a.exec();
}
